-module(p20).
%-export([result/0, main/1]).
-compile(export_all).

result() -> sum_of_digits(factorial(100)).

to_digit(Symbol) -> erlang:list_to_integer([Symbol]).

sum_of_digits(Number) ->
    SymbolsList = erlang:integer_to_list(Number),
    DigitsList = lists:map(fun to_digit/1, SymbolsList),
    lists:sum(DigitsList).

factorial(0) -> 1;
factorial(X) -> factorial(X - 1) * X.
